<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>TCP-Client</title>
</head>
<body>

<script>
    // 创建一个Socket实例bai
    var socket = new WebSocket("ws://127.0.0.1:12000");

// 打开Socket
        socket.onopen = function(event) {

            // 发送一du个初始化消息
            socket.send("Receiver Ready");
            console.log("success");

            // 监听消息
            socket.onmessage = function(event) {
                console.log(event.data);
            };

            // 监听Socket的关闭
            socket.onclose = function(event) {
                console.log("Connection closed");
            };

            // 关闭Socket…
            //socket.close()
        };
</script>
</body>
</html>
